package com.asd.map.service.impl;

import com.asd.map.entity.Information;
import com.asd.map.entity.Map_Information_point;
import com.asd.map.mapper.InformationMapper;
import com.asd.map.service.IInformationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author
 * @createtime 2021-09-02 9:49
 * @description
 */
@Service
public class InformationServiceImpl extends ServiceImpl<InformationMapper, Information> implements IInformationService {

    @Autowired
    private InformationMapper informationMapper;




    @Override
    public List<Information> selectInformationPage(Page<Information> page) {

        QueryWrapper<Information> queryWrapper = new QueryWrapper<>();
        //  判断年龄大于20岁的，这里用的是mybatis-plus的条件构造器
//        queryWrapper.gt("age",20);
        /**
         *    加上false就不查询总记录数啦,如果不需要的话可以加上false，这样就会少一条sql语句
         *   Page<Student> page = new Page<>(current,size,false);
         */
//        Page<Information> page1 = new Page<>();
        //   queryWrapper  可以为null  不进行条件判断
        //  返回list 调用  selectPage
        IPage<Information> informationIPage = informationMapper.selectPage(page, queryWrapper);


        //getRecords()分页对象记录列表
        List<Information> records = informationIPage.getRecords();
        return records;
    }


    @Override
    public void insertBatch(List<Information> list) {
        for (int i = 0; i < list.size(); i++) {
            Information information = new Information();
            information = list.get(i);
            informationMapper.insert(information);
//            System.out.println(list.get(i));
        }

    }


}
